package practice4;

import java.util.Scanner;

public class P2308 {
    public static void main(String[] args) {
        int[][] before=new int[101][101];
        int[][] after=new int[101][101];
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int m=sc.nextInt();
        for(int i=1;i<=n;i++) {
            for(int j=1;j<=m;j++) {
                before[i][j]=sc.nextInt();
            }
        }
        for(int i=1;i<=m;i++) {
            for(int j=1;j<=n;j++) {
                System.out.print(before[n-j+1][i]+" ");
            }
            System.out.println();
        }

    }
}
